import request from '@/api/request'
import { IPaginationFormWithCondition, ResponseFormat, ResponseFormatWithRows } from '@/types/http'

// 上传
export const upload = (data: FormData, params) => {
  return request.postFormData(`/uploader/single?categoryCode=${params.categoryCode}`, data)
}

// 多张上传
export const uploadBatch = (data: FormData, params) => {
  return request.postFormData(`/uploader/batchUpload?categoryCode=${params.categoryCode}`, data)
}

// 获取图片列表(可待条件筛选)
export const getImageList = (data: IPaginationFormWithCondition): Promise<ResponseFormatWithRows> => {
  return request.post('/uploader/find', data)
}

// 图片分类列表
export const getCategories = (params:any): Promise<ResponseFormat> => {
  return request.get('/uploader/categories', params)
}

// 新增图片分类
export const createCategory = (data): Promise<ResponseFormat> => {
  return request.post('/uploader/createCategory', data)
}

// 修改图片名称 update
export const updateImage = (data): Promise<ResponseFormat> => {
  return request.post('/uploader/updateImageName', data)
}
// 删除图片
export const delImg = (id:string): Promise<ResponseFormat> => {
  return request.get('/uploader/delImg', { params: { id } })
}

// 文件硬删除 delImgHard
export const delFileHard = (id: string): Promise<ResponseFormat> => {
  return request.get('/uploader/delFileHard', { params: { id } })
}

// 删除分类 delCategory
export const delCategory = (id:string): Promise<ResponseFormat> => {
  return request.get('/uploader/delCategory', { params: { id } })
}

// 修改分类名称 updateCategory
export const updateCategory = (data): Promise<ResponseFormat> => {
  return request.post('/uploader/updateCategory', data)
}
